﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ObjectModel.Excel;
using ViewModels;
using ObjectModel;

namespace ViewComponents
{
    /// <summary>
    /// Interaction logic for TargetRangeControl.xaml
    /// </summary>
    public partial class LinkedRangeControl : UserControl
    {
        LinkedRangesViewModel mViewModel;
        
        public LinkedRangeControl()
        {
            InitializeComponent();
        }

        public LinkedRangesViewModel ViewModel
        {
            get { return mViewModel; }
            set { mViewModel = value; }
        }

        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            ViewModel.AddLinkedRange();
        }

		private void RemoveButton_Click(object sender, RoutedEventArgs e)
		{
			ViewModel.RemoveLinkedRangeAt(LinkedRangeListBox.SelectedIndex);
		}

        private void RefreshButton_Click(object sender, RoutedEventArgs e)
        {
            ViewModel.UpdateSelected();
        }

        private void RefreshAllButton_Click(object sender, RoutedEventArgs e)
        {
            ViewModel.UpdateAll();
        }

        //private void LinkedRangeListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        //{
        //    ListBox listBox = ((ListBox)sender);
            
        //    if (listBox.SelectedIndex >= 0)
        //    {
        //        SourceRangeControl.DataContext = ((LinkedRange)listBox.SelectedItem).SourceRange;
        //        SourceRangeControl.Visibility = System.Windows.Visibility.Visible;
        //    }
        //    else
        //    {
        //        SourceRangeControl.DataContext = null;
        //        SourceRangeControl.Visibility = System.Windows.Visibility.Collapsed;
        //    }
        //}
    }
}
